Bash script - test not working as expected